{$cnt = 0}
<!-- <MAQUINAS> -->
<div style="height: 400px;">
    <table align="center">
        <caption>Semana {$semana}</caption>
        <thead>
                <tr>
                    <th rowspan="2">Maquina</th>
                    <th colspan="3">Turnos</th>
                    <th colspan="4">Tiempos</th>
                    <th colspan="3" style="background-color: azure;">Semana</th>
                    
                </tr>
                <tr>
                    <th>M</th>
                    <th>V</th>
                    <th>N</th>
                    <th>Minutos</th>
                    <th>Horas</th>
                    <th>T8</th>
                    <th>T9</th>
                    <th style="background-color: azure;">Minutos</th>
                    <th style="background-color: azure;">Horas</th>
                    <th style="background-color: azure;">T8</th>
                </tr>
            </thead>
            <tbody>
                {foreach from=$tabla item=curr_tab}
                {$mkns = $curr_tab.Maquina}
                
                <tr id="tr_{$cnt}">
                    <td><label name="{$cnt}" id="maq">{$curr_tab.Maquina}</label></td>
                    <td>
                        <select id="M{$cnt}" class="sl">
                            <option></option>
                            {foreach from=$oper.$mkns item=lst}
                            <option>{$lst.operador}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td>
                        <select id="V{$cnt}" class="sl">
                            <option></option>
                            {foreach from=$oper.$mkns item=lst}
                            <option>{$lst.operador}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td>
                        <select id="N{$cnt}" class="sl">
                            <option></option>
                            {foreach from=$oper.$mkns item=lst}
                            <option>{$lst.operador}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><label id="TTL">{$curr_tab.ttl}</label></td>
                    <td><label>{($curr_tab.ttl/60)|round:2}</label></td>
                    <td><label>{(($curr_tab.ttl/60)/8)|round:2}</label></td>
                    <td><label>{(($curr_tab.ttl/60)/9)|round:2}</label></td>
                    <td><label class="MIN">&nbsp;</label></td>
                    <td><label class="HRS">&nbsp;</label></td>
                    <td><label class="TRN">&nbsp;</label></td>
                </tr>
                {$cnt = $cnt+1}
                {/foreach}
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4">&nbsp;</td>
                    <td>{$tmin}</td>
                    <td>{($tmin/60)|round:2}</td>
                    <td>{(($tmin/60)/8)|round:2}</td>
                    <td>{(($tmin/60)/9)|round:2}</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </tfoot>
    </table>
</div>
<!-- </MAQUINAS> -->

<div>&nbsp;</div>

<!-- <OPERADORES> -->
<div id="oper">
    <table align="center">
    <thead>
        <tr>
            <th>#</th>
            <th>Nombre</th>
            <th>Maquinas</th>
            <th>Tiempo</th>
        </tr>
    </thead>
    <tbody>
    {foreach from=$operador item=opr}
        <tr>
            <td>{$opr.codigoanterior}</td>
            <td>{$opr.nombrecompleto}</td>
            <td>{$opr.maquinas}</td>
            <td>{$opr.tiempo}</td>
        </tr>
    {/foreach}
    </tbody>
</table>
</div>
<!-- </OPERADORES> -->

<script>
$(document).ready(function(){
    {$js}
    $("tr").each(function(){
        var fila= $(this).attr("id");
        var cnt = String(fila);
        cnt = parseInt(cnt.substring(3));
        var a=0,b=0,c=0,d=0;
        var m = '#' + fila + " #M" + cnt;
        var v = '#' + fila + " #V" + cnt;
        var n = '#' + fila + " #N" + cnt;
        
        m = $(m).val();
        v = $(v).val();
        n = $(n).val();
        
        if(m > 0){
            a = 1;
        }
        if(v > 0){
            b = 1;
        }
        if(n > 0){
            c = 1;
        }
        d = (a+b+c)*480;
        e = (d/60);
        f = (e/8);
        $('#' + fila + " .MIN").text(d);
        $('#' + fila + " .HRS").text(e);
        $('#' + fila + " .TRN").text(f);
        
        var mina = '#' + fila + " #TTL";
        var minb = '#' + fila + " .MIN";
        
        mina = $(mina).text();
        minb = $(minb).text();
        
        mina2 = parseInt(mina);
        minb2 = parseInt(minb);
        minc = mina2-minb2;
        
        if(mina2 > minb2){
            $("#" + fila).attr("style","background-color:lightcoral");
        }
        if(mina2 < minb2){
            $("#" + fila).attr("style","background-color:lightgreen");
        }
        if(minb == 0){
            $("#" + fila).attr("style","background-color:initial");
        }
    })
    
    $(".sl").change(function(){
        var p = $(this).parent().parent();
        var pp = $(p).attr("id");
        var nm = pp.substring(3);
        var maq = $("#" + pp + " #maq").text();
        var mat = $("#" + pp + " #M" + nm).val();
        var ves = $("#" + pp + " #V" + nm).val();
        var noc = $("#" + pp + " #N" + nm).val();
        var ttl = $("#" + pp + " #TTL").text();
        
        var x=0,y=0,z=0,a=0;
        if(mat != ''){
            x = 480;
        }
        if(ves != ''){
            y = 480;
        }
        if(noc != ''){
            z = 480;
        }
        a = x+y+z;
        b = a/60;
        c = b/8;
        $("#" + pp + " .MIN").text(a);
        $("#" + pp + " .HRS").text(b);
        $("#" + pp + " .TRN").text(c);
        
        var fila = pp;
        
        var mina = '#' + fila + " #TTL";
        var minb = '#' + fila + " .MIN";
        
        mina = $(mina).text();
        minb = $(minb).text();
        
        mina2 = parseInt(mina);
        minb2 = parseInt(minb);
        minc = mina2-minb2;
        
        if(mina2 > minb2){
            $("#" + fila).attr("style","background-color:lightcoral");
        }
        if(mina2 < minb2){
            $("#" + fila).attr("style","background-color:lightgreen");
        }
        if(minb == 0){
            $("#" + fila).attr("style","background-color:initial");
        }
        
        $.post("http://servidor1:82/maquinado/index/maqs",{
                    Matutino : mat,
                    Vesperti : ves,
                    Nocturno : noc,
                    Maquina : maq,
                    Semana : {$semana},
                    Minutos : ttl
                },function(data,status){
                    console.log(data);
                    $('#resultado').val(data);
                });
        $("#oper").html();
    });
    
    
});
</script>
<style>
    ul{
        margin:0;
    }
</style>